#include<iostream>
using namespace std;
int l,r,n,k;
int main(){
	freopen("candy.in","r",stdin); 
	freopen("candy.out","w",stdout); 
	cin>>n>>l>>r;
	for(int i=l;i<=r;i++)
		k=max(k,i%n);
	cout<<k;
	fclose(stdin);
	fclose(stdout);
	return 0;
} 
